<template>
  <div>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="limit"
      layout=" total, prev, pager, next, jumper,sizes"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";

export default {
  name: "Footer",
  data() {
    return {
      page: 1,
      limit: 5,
    };
  },
  async mounted() {
    this.getUsers({ page: this.page, limit: this.limit });
  },
  methods: {
    ...mapActions(["getUsers"]),
    handleSizeChange(limit) {
      // console.log(l);
      this.limit = limit;
      this.getUsers({ page: this.page, limit: this.limit });
    },
    handleCurrentChange(page) {
      // console.log(page);
      this.page = page;
      this.getUsers({ page: this.page, limit: this.limit });
    },
  },
  computed: {
    ...mapState(["lists", "total"]),
  },
};
</script>

<style>
.el-pagination {
  margin-top: 20px;
}
.el-pagination__sizes {
  float: right;
}
</style>